package com.bp.hearthealth.pulse.lnapps.ads.topon.interstitial_ad.listener.auto_load.ad_action

import android.content.Context
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.ATNetworkConfirmInfo
import com.anythink.core.api.AdError
import com.anythink.interstitial.api.ATInterstitialAutoEventListener
import com.bp.hearthealth.pulse.lnapps.bp_extension.LogUtil

/**
 * 自动加载 广告相关回调
 */
class ATInterstitialAutoEventListenerImpl : ATInterstitialAutoEventListener() {

    private var adEventListener: TopOnInterstitialAutoAdListener? = null

    fun setAutoEventListener(topOnInterstitialAutoEventListener: TopOnInterstitialAutoAdListener?) {
        this.adEventListener = topOnInterstitialAutoEventListener
    }

    override fun onInterstitialAdClicked(adInfo: ATAdInfo) {
        adEventListener?.onInterstitialAdClicked(adInfo)
        LogUtil.iTopOn(
            "TopOn 插页广告 onInterstitialAdClicked:$adInfo"
        )
    }

    override fun onInterstitialAdShow(adInfo: ATAdInfo) {
        adEventListener?.onInterstitialAdShow(adInfo)
        LogUtil.iTopOn(
            "TopOn 插页广告 onInterstitialAdShow:$adInfo"
        )
    }

    override fun onInterstitialAdClose(adInfo: ATAdInfo) {
        adEventListener?.onInterstitialAdClose(adInfo)
//        LogUtil.iTopOn(
//            "TopOn 插页广告 onInterstitialAdClose:$adInfo"
//        )
    }

    override fun onInterstitialAdVideoStart(adInfo: ATAdInfo) {
        adEventListener?.onInterstitialAdVideoStart(adInfo)
        LogUtil.iTopOn(
            "TopOn 插页广告 onInterstitialAdVideoStart:$adInfo"
        )
    }

    override fun onInterstitialAdVideoEnd(adInfo: ATAdInfo) {
        adEventListener?.onInterstitialAdVideoEnd(adInfo)
        LogUtil.iTopOn(
            "TopOn 插页广告 onInterstitialAdVideoEnd:$adInfo"
        )
    }

    override fun onInterstitialAdVideoError(adError: AdError) {
        adEventListener?.onInterstitialAdVideoError(adError)
        LogUtil.iTopOn(
            "TopOn 插页广告 onInterstitialAdVideoError:" + adError.fullErrorInfo
        )
    }

    override fun onDeeplinkCallback(adInfo: ATAdInfo, isSuccess: Boolean) {
        adEventListener?.onDeeplinkCallback(adInfo, isSuccess)
        LogUtil.iTopOn(
            "TopOn 插页广告 onDeeplinkCallback:\n$adInfo| isSuccess:$isSuccess"
        )
    }

    override fun onDownloadConfirm(
        context: Context, adInfo: ATAdInfo, networkConfirmInfo: ATNetworkConfirmInfo
    ) {
        adEventListener?.onDownloadConfirm(context, adInfo, networkConfirmInfo)
        LogUtil.iTopOn(
            "TopOn 插页广告 onDownloadConfirm:\n$adInfo"
        )
    }
}
